from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


class Base():
    def __init__(self):
        cop={"platformName": "Android",
  "deviceName": "127.0.0.1:7555",
  "noReset": True,
  "appPackage": "cn.xuexi.android",
  "appActivity": "com.alibaba.android.rimet.biz.home.activity.HomeActivity"}
        self.drivce=webdriver.Remote('http://127.0.0.1:4723/wd/hub',cop)
        self.drivce.implicitly_wait(15)
    def find_ele(self,loc):
        ele=self.drivce.find_element(*loc)
        return ele
    def find_ele_w(self,loc):
        ele=WebDriverWait(self.drivce,15).until(EC.element_to_be_clickable(loc))
        return ele
    # 截图
    def jt(self,a):
        self.drivce.save_screenshot(a)
    # 滑动
    def hd(self,q,w,e,r):
        self.drivce.swipe(q,w,e,r,100)
    # 轻敲
    def qq(self,x,y):
        self.drivce.tap([(x,y)],100)
    # 退出
    def tc(self):
        self.drivce.quit()